<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"       
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:c="http://java.sun.com/jsp/jstl/core">
 <h:head><title>Property Unit Update</title></h:head>
 
 <body>
 	 <ui:composition template="/template/main_template.xhtml">
 	 	 <ui:define name="content">
 	 	 
 	 	 <p:panel id="panel" header="Property Unit List " style="width:95%">  			
		    <h:form id="puListForm">
		    <input type="hidden" name="selectedProjectId" value="#{propertyUnitUpdateBean.selectedProjectId}" />
		    <p:outputPanel id="searchPanel"   styleClass="no-borders">
					<p:focus context="puListForm"/>
					
					<p:growl id="growlForm" showDetail="true" life="3000" autoUpdate="false" /> 
				<p:panelGrid style="width:100%; background-color: lightgrey;" styleClass="no-borders">
					<p:row>
						<p:column style="width:15%;text-align:right; margin-right:5px;vertical-align:middle" id="projectName">
							<p:outputLabel  value="Project Name"/>
						</p:column>
						<p:column style="width:40%;text-align:left;vertical-align:middle">											
							<p:selectOneMenu id="projectList" value="#{propertyUnitUpdateBean.selectedProjectId}"  requiredMessage="Project Name is mandatory"
								 required="true" style="width:100%" for="projectName">  
								<f:selectItems value="#{propertyUnitUpdateBean.projects}"/>
							</p:selectOneMenu>
						</p:column>
						<p:column style="width:15%;text-align:right; margin-right:5px;vertical-align:middle" id="UnitNoLbl">
							<p:outputLabel  value="Unit No"/>
						</p:column>
						<p:column style="width:15%;text-align:left;vertical-align:middle">
							 <p:inputText id="unitTxt" value="#{propertyUnitUpdateBean.unit}" style="text-transform:uppercase" />
						</p:column>
						<p:column  style="width:15%;text-align:left;vertical-align:middle">
							 <p:commandButton value = "Search" action="#{propertyUnitUpdateBean.searchProject}" ajax="false" process="projectList,unitTxt" update=":puListForm:resultsPanel"/>.
						</p:column>
					</p:row>
				</p:panelGrid>
				<br/>
				</p:outputPanel>
 	 	 	<p:outputPanel id="resultsPanel" rendered = "#{propertyUnitUpdateBean.selectedProjectId != null}" >
 	 	 	
 		 	 	<p:dataTable id="dt" var="dto" value="#{propertyUnitUpdateBean.dtoList}" draggableColumns="true" resizableColumns="false" paginatorPosition="bottom" paginatorAlwaysVisible="false"
 		 	 			paginator="true" rows="10"  rowsPerPageTemplate="5,10,15" tableStyle="width:100%" 
                 paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} "  >  
                 
    			    <p:column headerText="Unit No" sortBy="#{dto.projectInvetory.unitNo}">  
            			<p:outputLabel  value="#{dto.projectInvetory.unitNo}" />  
        			</p:column>
        			 <p:column headerText="Purchaser Name" sortBy="#{dto.customer.fullName}">  
            			<p:outputLabel  value="#{dto.customer.fullName}" />  
        			</p:column>
        			 <p:column headerText="Selling Price(RM)" sortBy="#{dto.projectInvetory.purchasePrice}" style="text-align:right">          			 
            			<h:outputText  value="#{dto.projectInvetory.purchasePrice}"  style="text-align:right" >
            				<f:convertNumber pattern="#,###,##0.00"   />
            			</h:outputText>  
        			</p:column>
        			 <p:column headerText="Purchased Date" sortBy="#{dto.account.datePurchased}" style="text-align:center">  
            			<h:outputText  value="#{dto.account.datePurchased}"  >
            				<f:convertDateTime type="date" pattern="#{propertyUnitUpdateBean.dateFormat}" />
            			</h:outputText>     
        			</p:column>
        			 <p:column headerText="SPA Date" sortBy="#{dto.account.spaSignedDate}" style="text-align:center">  
            			<h:outputText  value="#{dto.account.spaSignedDate}"  >
            				<f:convertDateTime type="date" pattern="#{propertyUnitUpdateBean.dateFormat}" />
            			</h:outputText>      
        			</p:column>
        			 <p:column headerText="LO Date" sortBy="#{dto.account.loSignedDate}" style="text-align:center">  
            			<h:outputText  value="#{dto.account.loSignedDate}" >
            				<f:convertDateTime type="date" pattern="#{propertyUnitUpdateBean.dateFormat}" />
            			</h:outputText>     
        			</p:column>
        			 <p:column headerText="LA Date" sortBy="#{dto.account.laSignedDate}" style="text-align:center">  
            			<h:outputText  value="#{dto.account.laSignedDate}"  >
            				<f:convertDateTime type="date" pattern="#{propertyUnitUpdateBean.dateFormat}" />
            			</h:outputText>     
        			</p:column>
        			
        			<p:column style="width:4%">  
			                <p:commandButton id="selectDTOBtn" update=":dialogForm:dialogPanel" oncomplete="dlg.show()" icon="ui-icon-search" title="View" >  
			                <f:setPropertyActionListener value="#{dto}" target="#{propertyUnitUpdateBean.selectedDto}" />  
			            </p:commandButton>  
			        </p:column> 
        			
		        </p:dataTable> 
				</p:outputPanel>
				</h:form>
				<h:form id="dialogForm">
				<p:outputPanel id="dialogPanel">
				 <p:dialog id="tDialog" header="Property Unit Details" widgetVar="dlg"
				        modal="true" height="550" width="750"  showEffect="explode"
				        hideEffect="explode">
				        
				        <p:growl id="growl" showDetail="true" life="3000" autoUpdate="false" /> 
				        <h:panelGrid id="display" columns="4" cellpadding="4" width="100%">
				            
				            <p:outputLabel  value="Project Name" />
				            <p:inputText value="#{propertyUnitUpdateBean.selectedDto.project.projectName}" disabled="true"/>
				            <p:outputLabel  value="Project Code" />
				            <p:inputText value="#{propertyUnitUpdateBean.selectedDto.project.projectCode}"  disabled="true"/>		
				        
				        
				            <p:outputLabel  value="Unit No" />
				            <p:inputText value="#{propertyUnitUpdateBean.selectedDto.projectInvetory.unitNo}" disabled="true" style="width:35%"/>
				            <p:outputLabel  value="Built Up Area" />
				            <h:panelGroup>
					            <p:inputText value="#{propertyUnitUpdateBean.selectedDto.projectInvetory.builtUpArea}"  disabled="true" style="width:35%;text-align:right">
					            	<f:convertNumber type="number"   />
					            </p:inputText>
					            <p:outputLabel  value="Sq.ft."  style="padding-left:10px; "/>
				            </h:panelGroup>
				            		
				        
				            <p:outputLabel  value="Selling Price" />
				            <p:inputText value="#{propertyUnitUpdateBean.selectedDto.projectInvetory.purchasePrice}"  disabled="true"  style="text-align:right">
            					<f:convertNumber pattern="#,###,##0.00"   />
            				</p:inputText>  
				            <p:outputLabel  value="Discount Rate" />
				            <h:panelGroup>
					            <p:inputText value="#{propertyUnitUpdateBean.selectedDto.projectInvetory.discountRate}"  disabled="true"  style="text-align:right">
					           		 <f:convertNumber type="number" minFractionDigits="1" maxFractionDigits="2"/>
					            </p:inputText>	
					             <p:outputLabel  value="%"  style="padding-left:10px; "/>
				            </h:panelGroup>
				            
				             <p:outputLabel  value="Nett Price" />
				            <p:inputText value="#{propertyUnitUpdateBean.selectedDto.projectInvetory.nettPrice}"  disabled="true"   style="text-align:right">
				            	<f:convertNumber pattern="#,###,##0.00"   />
            				</p:inputText>  	
				            <p:outputLabel  value="Discount Amount" />
				            <p:inputText value="#{propertyUnitUpdateBean.selectedDto.projectInvetory.discountAmount}"  disabled="true" style="text-align:right" >
				            	<f:convertNumber pattern="#,###,##0.00"   />
            				</p:inputText>  
				            
				            <p:outputLabel  value="HSD No"  />
				            <p:inputText value="#{propertyUnitUpdateBean.selectedDto.projectInvetory.hsdNo}"  style="width:50%; text-transform:uppercase"/>
				            <p:outputLabel  value="PT No" />
				            <p:inputText value="#{propertyUnitUpdateBean.selectedDto.projectInvetory.ptNo}"   style="width:50%; text-transform:uppercase"/>
				            
				            <p:outputLabel  value="Address Line 1" />
				            <p:inputText value="#{propertyUnitUpdateBean.selectedDto.address.addressLine1}" style="text-transform:uppercase"  />
				            <p:outputLabel  value="Address Line 2" />
				            <p:inputText value="#{propertyUnitUpdateBean.selectedDto.address.addressLine2}" style="text-transform:uppercase"  />
				            
				            <p:outputLabel  value="Address Line 3" />
				            <p:inputText value="#{propertyUnitUpdateBean.selectedDto.address.addressLine3}" style="text-transform:uppercase"  />
				            <p:outputLabel  value="Address Line 4" />
				            <p:inputText value="#{propertyUnitUpdateBean.selectedDto.address.addressLine4}" style="text-transform:uppercase"  />
				            
				            <p:outputLabel  value="Post Code" />
				            <p:inputText value="#{propertyUnitUpdateBean.selectedDto.address.postcode}"  style="width:50%"/>
				            <p:outputLabel  value="City" />
				            <p:inputText value="#{propertyUnitUpdateBean.selectedDto.address.city}" style="width:50%; text-transform:uppercase"/>
				           
				            <p:outputLabel id="stateTxt" value="State" />
				            <p:selectOneMenu id="stateTypeList" value="#{propertyUnitUpdateBean.selectedDto.address.state}"  requiredMessage="Please Select Any State"
								 required="false" style="width:100%" for="stateTxt">  
								<f:selectItems value="#{propertyUnitUpdateBean.statesSIList}"/>
							</p:selectOneMenu>
				            <p:outputLabel  value="Handover Date" />
				            <p:calendar value="#{propertyUnitUpdateBean.selectedDto.projectInvetory.keyHandoverDate}" id="popupButtonCal1"   showOn="button" style="width:50%"/>
				            
				             <p:outputLabel id="titleTypeTxt"  value="Title Type" />
				             <p:selectOneMenu id="titleTypeList" value="#{propertyUnitUpdateBean.selectedDto.projectInvetory.propertyTitleType}"  requiredMessage="Please Select Any Title Type"
								 required="false" style="width:100%" for="titleTypeTxt">  
								<f:selectItems value="#{propertyUnitUpdateBean.titlTypesSIList}"/>
							</p:selectOneMenu>				     
				            <p:outputLabel  value="Strata Title Date" />
				            <p:calendar value="#{propertyUnitUpdateBean.selectedDto.projectInvetory.strataTitleObtainedDate}" id="popupButtonCal2"  showOn="button" style="width:50%"/>
				           

							 <p:outputLabel  value="Disbursment Fee" />
				            <p:inputText id="disbursmentFee" value="#{propertyUnitUpdateBean.selectedDto.projectInvetory.disbursementFee}" 
				            	converter="javax.faces.BigDecimal" converterMessage="Please enter valid Disbursment Fee amount"  style="width:50%;text-align:right" >
				            	<f:convertNumber pattern="#,###,##0.00"   />
            				</p:inputText>  
				            <p:outputLabel  value="Redemption Amount" />
				            <p:inputText id="RedemptionAmount" value="#{propertyUnitUpdateBean.selectedDto.projectInvetory.redemptionAmount}" converter="javax.faces.BigDecimal" converterMessage="Please enter valid redemption amount" style="width:50%;text-align:right" >
				            <f:convertNumber pattern="#,###,##0.00"   />
            				</p:inputText>  
				            
				             <p:outputLabel  value="SPA Legal Fee" />
				            <p:inputText id="spaLegalFee" value="#{propertyUnitUpdateBean.selectedDto.projectInvetory.legalFee}" 				            
				            	converter="javax.faces.BigDecimal" converterMessage="Please enter valid SPA legal fee amount" style="width:50%;text-align:right">
				            	<f:convertNumber pattern="#,###,##0.00"   />
            				</p:inputText>  
				            <p:outputLabel  value="DMC Date" />
				            <p:calendar value="#{propertyUnitUpdateBean.selectedDto.projectInvetory.dncDate}" id="popupButtonCal3" showOn="button"  />
				            	
				            				            			            
				            <p:outputLabel value=""/>
				            <p:commandButton value = "Close" actionListener="#{propertyUnitUpdateBean.closePUDetails}" ajax="true" partialSubmit="true" update="growl,:puListForm:resultsPanel" style="margin-top:20px;float:right"
							 oncomplete="handleSaveRequest(xhr, status, args)"/>				            			            
							<p:commandButton value = "Save" actionListener="#{propertyUnitUpdateBean.savePUDetails}" ajax="true" update="growl" style="margin-top:20px"
							 oncomplete="handleSaveRequest(xhr, status, args)"/>
							 <p:outputLabel value=""/>				            				            			            
				        </h:panelGrid>				        
				    </p:dialog> 
				    <script type="text/javascript">  
						    function handleSaveRequest(xhr, status, args) {  
						        if(args.validationFailed || !args.success) {  
						            dlg.jq.effect("shake", { times:5 }, 100);
						            
						        }   
						        else {  
						        	dlg.hide();
						           // PF('dlg').hide();  
						           // $('#loginLink').fadeOut();  
						        }  
						    }  
						</script>  
				 </p:outputPanel> 
 	 	 	
 	 	 	</h:form>
		</p:panel>
 	 	</ui:define>
 	 </ui:composition>
 	 
 	 
 </body>
</html> 
